package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageDTO;
import com.sky.entity.Dish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface DishMapper {
    @Select("select count(*) from dish where category_id=#{id}")
    Integer findByCategoryId(Long id);

    @Select("select * from dish where name like concat('%',#{name},'%')")
    Dish findByName(String name);
    @AutoFill("insert")
    void save(Dish dish);

    List<DishVO> findByList(DishPageDTO dto);


    void deleteByIds(@Param("ids") List<Long> ids);

    Integer findByIds(@Param("ids") List<Long> ids);
    @Select("select * from dish where id=#{id}")
    Dish findById(Long id);
    @AutoFill("update")
    void update(Dish dish);


    void updateStatusBySetmealIds(List<Long> ids, Integer status, LocalDateTime updateTime, Long updateUser);
    @Select("select count(*) from dish where  status=0 and id in (select dish_id from setmeal_dish where setmeal_id=#{setmealId} )")
    Integer findBySetmealId(Long setmealId);
    @Select("select count(*) from dish where status=#{status}")
    Integer countStatus(Integer status);
}
